<template>
  <MkDialog v-model="ctx.dialogValue" title="大量用血" width="70%" :draggable="false">
    <div id="printDaLiangYongXue">
      <MkPanel title="大量用血信息">
        <MkPatient ref="patientRef" v-model="ctx.huanZhe" />
        <MkDescription>
          <MkDescriptionItem label="大量用血原因">{{ ctx.entity.daLiangYongXueYuanYin }}</MkDescriptionItem>
          <MkDescriptionItem label="累计申请总量">{{ ctx.entity.leiJiShenQingLiang }}ml</MkDescriptionItem>
        </MkDescription>
      </MkPanel>

      <MkPanel title="累计申请用血信息">
        <MkTable :data="ctx.yongXueList">
          <MkColumn prop="id" label="申请单号" />
          <MkColumn prop="xueYePinZhong" label="血液品种" />
          <MkColumn prop="beiXueLiang" label="申请量" />
        </MkTable>
      </MkPanel>
      <MkPanelEdit title="临床科主任审核" :showButton="ctx.isKeZhuRenEdit">
        <template #button>
          <el-button class="no-print ml10" type="success" icon="ele-Finished" @click="keZhuRenShenHe">审 核</el-button>
        </template>
        <MkForm :col="3">
          <MkSelectUser label="审核人" v-model="ctx.entity.keZhuRenShenHeRenId" :isEdit="ctx.isKeZhuRenEdit" />
          <MkDatePicker label="审核时间" v-model="ctx.entity.keZhuRenShenHeShiJian" :isEdit="ctx.isKeZhuRenEdit" />
          <MkInput label="审核信息" v-model="ctx.entity.keZhuRenShenHeXinXi" :col="2" :isEdit="ctx.isKeZhuRenEdit" />
        </MkForm>
      </MkPanelEdit>
      <MkPanelEdit title="输血科审核" :isShowButton="ctx.isShuXueKeEdit">
        <template #button>
          <el-button class="no-print ml10" type="success" icon="ele-Finished">审 核</el-button>
        </template>
        <MkForm :col="3">
          <MkSelectUser label="审核人" v-model="ctx.entity.shuXueKeShenHeRenId" :isEdit="ctx.isShuXueKeEdit" />
          <MkDatePicker label="审核时间" v-model="ctx.entity.shuXueKeShenHeShiJian" :isEdit="ctx.isShuXueKeEdit" />
          <MkInput label="审核信息" v-model="ctx.entity.shuXueKeShenHeXinXi" :col="2" :isEdit="ctx.isShuXueKeEdit" />
        </MkForm>
      </MkPanelEdit>
      <MkPanelEdit title="医务科审核" :showButton="ctx.isYiWuEdit">
        <template #button>
          <el-button class="no-print ml10" type="success" icon="ele-Finished">审 核</el-button>
        </template>
        <MkForm :col="3">
          <MkSelectUser label="审核人" v-model="ctx.entity.yiWuKeShenHeRenId" :isEdit="ctx.isYiWuEdit" />
          <MkDatePicker label="审核时间" v-model="ctx.entity.yiWuKeShenHeShiJian" :isEdit="ctx.isYiWuEdit" />
          <MkInput label="审核信息" v-model="ctx.entity.yiWuKeShenHeXinXi" :col="2" :isEdit="ctx.isYiWuEdit" />
        </MkForm>
      </MkPanelEdit>


    </div>

    <template #footer>
      <el-button size="default" @click="ctx.dialogValue = false">关 闭</el-button>
    </template>
  </MkDialog>
</template>

<script lang='ts' setup>
import useVeriftyPwd from '/@/hooks/useVeriftyPwd'


interface daLiangYongXue {
  daLiangYongXueYuanYin: string
  leiJiShenQingLiang: number
  keZhuRenShenHeRenId: number
  keZhuRenShenHeShiJian: string
  keZhuRenShenHeXinXi: string
  shuXueKeShenHeRenId: number
  shuXueKeShenHeShiJian: string
  shuXueKeShenHeXinXi: string
  yiWuKeShenHeRenId: number
  yiWuKeShenHeShiJian: string
  yiWuKeShenHeXinXi: string
}
const initState = () => {
  return {
    entity: {} as daLiangYongXue,
    huanZhe: {
      huanZheId: '001101',
      xingMing: '张三',
      chuShaiABO: 'A',
      chuShaiRhD: '+',
      xingBie: '男',
      nianLing: '23岁',
      bingQu: '血液内科',
      chuangHao: '3',
      jiuZhenLeiXing: '门诊',
    },
    yongXueList: [{
      xueYePinZhong: '悬浮红细胞',
      beiXueLiang: '2u',
      id: '250617001'
    }, {
      xueYePinZhong: '悬浮红细胞',
      beiXueLiang: '2u',
      id: '250617002'
    }, {
      xueYePinZhong: '悬浮红细胞',
      beiXueLiang: '4u',
      id: '250617003'
    }],
    dialogValue: false,
    isKeZhuRenEdit: false,
    isShuXueKeEdit: false,
    isYiWuEdit: false,
  }
}
const ctx = reactive(initState())

const loadingEntity = (row) => {
  ctx.dialogValue = true
  // TODO 获取大量用血数据
  ctx.isKeZhuRenEdit = true
  // TODO 设置默认值

}

const keZhuRenShenHe = () => {
  useVeriftyPwd({ title: '临床科主任审核', entityId: '' }, ctx.entity.keZhuRenShenHeRenId).then(userInfo => {
    ctx.dialogValue = false
  })
}

defineExpose({ loadingEntity })
</script>

<style lang='scss' scoped></style>
